package com.meishij.fragment.malldetailfragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.google.gson.Gson;
import com.meishij.R;
import com.meishij.adapter.MallItemDetailAdapter;
import com.meishij.entry.MallSellEntry;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class MallItemDetailFragment extends Fragment {


    private View view;

    private MallItemDetailAdapter mallItemDetailAdapter;

    private List<String> logoList=new ArrayList<>();
    private List<Object> list=new ArrayList<>();
    private RecyclerView detail_recyclerView;

    public MallItemDetailFragment() {
        // Required empty public constructor

    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if(view!=null){
            return view;
        }
        view = inflater.inflate(R.layout.fragment_mall_item_detail, container, false);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        Bundle bundle = getArguments();
        MallSellEntry.ObjBean data = (MallSellEntry.ObjBean) bundle.getSerializable("data");
        detail_recyclerView = ((RecyclerView) view.findViewById(R.id.mall_sell_item_detail_recyclerView));
        GridLayoutManager layoutManager = (GridLayoutManager) detail_recyclerView.getLayoutManager();
        layoutManager.setSpanCount(1);
        List<MallSellEntry.ObjBean.DetailBean> detail = data.getDetail();
        String logoUrl = data.getStore_infomation().getLogo();
        logoList.add(logoUrl);
        list.add(0,detail);
        list.add(1,logoList);
        list.add(2,null);
        mallItemDetailAdapter = new MallItemDetailAdapter(getContext(),list,new int[]{
            R.layout.layout_mall_item_detail_item_recycler,
                R.layout.layout_mall_item_bottom_loge,
                R.layout.layout_mall_detail_item_bottom_text
        });
        detail_recyclerView.setAdapter(mallItemDetailAdapter);

    }
}
